<template>
  <transition name="fade">
    <div class="alert lcckup-message-bg" v-if="isShow">
      <strong style="display:block">Warning! </strong>
      <font>{{message}}</font>
      <a class="close lcckup-message-close" @click="close">×</a>
    </div>
  </transition>
</template>

<script type="text/javascript">
  export default {
    name: 'lcckup-message-bg',
    data () {
      return {
        message: '',
        time: 3000,
        isShow: true
      }
    },
    mounted () {
      this.automaticClose()
    },
    methods: {
      close () {
        this.isShow = false
      },
      automaticClose () {
        let _this = this
        window.setTimeout(function() {
          _this.isShow = false
        }, this.time);
      }
    }
  }
</script>

<style type="text/css">
  .lcckup-message-bg {
    position: fixed;
    right: -5px;
    top: 0;
    min-width: 250px;
    max-width: 320px;
    padding: 10px 15px;
    margin: 35px;
    border-radius: 4px;
    background-color: #BF4951;
    color: #fff;
    z-index: 999999999
  }

  .lcckup-message-bg font {
    padding-left: 15px;
  }

  .lcckup-message-bg .lcckup-message-close {
    position: absolute;
    right: 0;
    top: 0;
    line-height: 100%;    
    margin: 5px 5px 0 0;
    color: #fff;
    font-weight: normal;
    opacity: 0.8;
    filter: alpha(opacity=80);
  }

  .fade-enter-active, .fade-leave-active {
    transition: all .5s
  }
  .fade-enter, .fade-leave-to {
    transform: translate3d(100%, 0, 0);
    opacity: 0;
  }
</style>